package com.example.demo.config;

/** <a href="http://www.cpupk.com/decompiler">Eclipse Class Decompiler</a> plugin, Copyright (c) 2017 Chen Chao. */

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * 参数常量表.
 * 
 */
public class ParaHelper {

    /** confiProperties. */
    private static Properties confiProperties;

    /**
     * 
     * @return String
     */
    public static String clearConfiProperties() {
        try {
            ParaHelper.confiProperties.clear();
        } catch (Exception e) {
            /** Exception handle. */
            e.printStackTrace();
        }
        return "清除 confiProperties 配置缓存成功！";
    }

    /**
     * 获取配置文件下特定路径.
     * 
     * @param property 
     * @return String
     */
    public static String getPath(String property) {
        if (confiProperties == null) {
            synchronized (ParaHelper.class) {
                if (confiProperties == null) {
                    confiProperties = new Properties();
                    InputStream is = null;
                    try {
                        is = Thread.currentThread().getContextClassLoader().getResourceAsStream("bankAuthority-config.properties");
                        confiProperties.load(is);
                    } catch (IOException e) {
                        /***/
                    } finally {
                        /**关闭输入流*/
                        if (is != null) {
                            try {
                                is.close();
                            } catch (IOException e1) {
                                /**抛出异常*/
                                e1.printStackTrace();
                            }
                        }
                    }
                }
            }
        }
        return confiProperties.getProperty(property);
    }
}